#pragma once
#include "wc3collections.h"
#include "wc3observer.h"
#include "wc3agent.h"

	class TGameVarChangedEvent : public TEvent
	{
	public:
		Single NewValue;
	};

	struct THandle2AgentReg
	{
		Dword References;
		PAgent Value;
		LongBool AutoDestroy;
	};

	typedef THandle2AgentReg* PHandle2AgentReg;

	//template <class TCaseInsensetiveStringHashKeyManager, class TFloat, class TInteger, class THandle2AgentReg>
	class TGameState : public TAgentWar3
	{
	public:
		typedef TSGrowableArray<Dword> TEventDataStack;

		class TAgent2HandleReg : public TSHashObject<Dword>
		{
		public:
			Dword Handle;
			Dword BirthTag;
		};

		class TGameVarEventReg : public TSHashObject<PChar>
		{
		public:
			PObserver Observer;
		};
		typedef TGameVarEventReg* PGameVarEventReg;
	public:
		Dword field24;
		TFloat Floats[1];
		Dword field38;
		TInteger Integers[2];
		TFloat Float5C;
		Dword field6C;
		Dword field70;
		Dword field74;
		Dword field78;
		Dword field7C;
		TInteger Integer80;
		Dword EventDataArraysCount;
		TEventDataStack EventDataStack[15];
		TSGrowableArray<Dword> FreeHandles;
		TSGrowableArray<THandle2AgentReg> Handle2AgentRegList;
		TSHashTable<Dword, TAgent2HandleReg, THashlessKeyManager> Agent2HandleTable;
		TSHashTable<Dword, TAgent2HandleReg, THashlessKeyManager> Func2AgentTable;
		TSHashTable<Dword, TAgent2HandleReg, THashlessKeyManager> Filter2AgentTable;
		TSHashTable<PChar, TGameVarEventReg, TCaseInsensetiveStringHashKeyManager> GameVarChangeEventPublishers;
		//GameVarChangedEvent: TGameVarChangedEvent;
		//HastTable_HERONAMESUSED: TSHashTable;
		//UpdateFogTimer_: CAgentTimer;
		//AgentTimer294: CAgentTimer;
		//AgentTimer2A8: CAgentTimer;
		//kQuestManager: Keys;
		//field2C4: DWORD;
		//AggregatedTextTagManager: DWORD;
		//field2CC: DWORD;
		//field2D0: DWORD;
		//field2D4: DWORD;
		//field2D8: DWORD;
		//field2DC: DWORD;
		//field2E0: DWORD;
		//field2E4: DWORD;
		//field2E8: DWORD;
		//field2EC: DWORD;
		//field2F0: DWORD;
		//field2F4: DWORD;
		//field2F8: DWORD;
		//field2FC: DWORD;
		//field300: DWORD;
		//field304: DWORD;
		//field308: DWORD;
		//field30C: DWORD;
		//field310: DWORD;
		//field314: DWORD;
		//field318: DWORD;
		//field31C: DWORD;
		//field320: DWORD;
		//field324: DWORD;
		//field328: DWORD;
		//field32C: DWORD;
		//field330: DWORD;
		//field334: DWORD;
		//field338: DWORD;
		//field33C: DWORD;
		//field340: DWORD;
		//field344: DWORD;
		//field348: DWORD;
		//field34C: DWORD;

	public:
		PObserver GetVarChangeEventPublisher(PChar VariableName);
	};

	//typedef TGameState<TCaseInsensetiveStringHashKeyManager,TFloat,TInteger,THandle2AgentReg>* PGameState;
	typedef TGameState* PGameState;